<?php

class AdType extends AppModel {

    public $name  = 'AdType';
    public $order = 'AdType.name ASC';

    public $validate = array(
        'name' => array(
            'rule'    => 'notEmpty',
            'message' => 'Morate uneti naziv'
        ),
        'price' => array(
            'rule'       => '/^\d+(\.\d+)?$/',
            'allowEmpty' => false,
            'message'    => 'Morate uneti cenu izrade'
        ),
    );
	
	public static function calculateIndex($unit, $width, $height) {
		switch($unit) {
            default:
                $index = 0;
                break;
            
            case 'kom':
                $index = 1;
                break;
            
            case 'm²':
                $index = (float)$width * (float)$height;
                break;
        }
		
		return $index;
	}
}

?>